home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ANIVGA.ZIP / EXAMPLE1.PAS < prev    next >
Pascal/Delphi Source File  |  1992-08-18  |  2KB  |  54 lines

  1. PROGRAM Example1;
  2. USES ANIVGA,CRT;
  3. CONST LoadNumber=42; {why not 42? - A hello to all Douglas Adam fans!}
  4.       SpriteName='FLOWER.COD'; {Path and name of the sprite to load}
  5.       Sprite1=0;
  6.       Sprite2=5;
  7.       ch:CHAR=#0; {sets ch to that value everytime the program starts}
  8. VAR collide:BOOLEAN;
  9.  
  10. BEGIN
  11.  IF loadSprite(SpriteName,LoadNumber)=0
  12.   THEN BEGIN
  13.         CloseRoutines;
  14.         WRITELN('Error: '+GetErrorMessage); halt(1)
  15.        END;
  16.  
  17.  InitGraph;
  18.  
  19.  Color:=66;
  20.  BackgroundLine(0,0,XMAX,0); BackgroundLine(XMAX,0,XMAX,YMAX);
  21.  BackgroundLine(XMAX,YMAX,0,YMAX); BackgroundLine(0,YMAX,0,0);
  22.  BackgroundOutTextXY(100,70,'Hello world!');
  23.  
  24.  SpriteN[Sprite1]:=LoadNumber;
  25.  SpriteX[Sprite1]:=0; SpriteY[Sprite1]:=0;
  26.  
  27.  SpriteN[Sprite2]:=LoadNumber;
  28.  SpriteX[Sprite2]:=XMAX SHR 1; SpriteY[Sprite2]:=YMAX SHR 1;
  29.  
  30.  Animate;
  31.  REPEAT
  32.   collide:=Hitdetect(Sprite1,Sprite2);
  33.   if collide THEN BEGIN Sound(1000); Delay(5); NoSound END;
  34.   if KeyPressed
  35.    THEN BEGIN
  36.          WHILE KeyPressed do ch:=UpCase(ReadKey);
  37.          CASE ch OF
  38.           'I':DEC(SpriteY[0]);
  39.           'J':DEC(SpriteX[0]);
  40.           'K':INC(SpriteX[0]);
  41.           'M':INC(SpriteY[0]);
  42.           'E':dec(StartVirtualY,10);  {change position of whole scene with}
  43.           'S':dec(StartVirtualX,10);  {E,S,D,X}
  44.           'D':inc(StartVirtualX,10);
  45.           'X':inc(StartVirtualY,10);
  46.          END;
  47.          IF POS(ch,'IJKMESDX')>0 THEN Animate;
  48.         END;
  49.  
  50.  UNTIL (ch='Q') OR (ch=#27);
  51.  
  52.  CloseRoutines;
  53. END.
  54.